package com.team.recruitment_management_system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.team.recruitment_management_system.mapper.ResumeMapper;
import com.team.recruitment_management_system.pojo.dto.resume.AddResumeDto;
import com.team.recruitment_management_system.pojo.entity.Resume;
import com.team.recruitment_management_system.pojo.vo.ResumeVo;
import com.team.recruitment_management_system.service.ResumeService;
import com.team.recruitment_management_system.util.JwtHelper;
import com.team.recruitment_management_system.util.result.Result;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 86147
* @description 针对表【resume(简历表)】的数据库操作Service实现
* @createDate 2024-03-21 20:28:40
*/
@Service
public class ResumeServiceImpl extends ServiceImpl<ResumeMapper, Resume>
    implements ResumeService{
    @Autowired
    ResumeMapper resumeMapper;
    @Autowired
    JwtHelper jwtHelper;
    public ResumeVo FindOne(String token){
        Integer userId = jwtHelper.getUserId(token);
        return resumeMapper.selectByUserId(userId);
    }
    public Result addOne(AddResumeDto addResumeDto){
        Resume resume = new Resume();
        BeanUtils.copyProperties(addResumeDto,resume);
        this.save(resume);
        Integer generatedId = resume.getId(); // 获取插入成功后的 ID
        return Result.ok(generatedId);
    }

    @Override
    public List<Resume> listByIds(List<Integer> list) {
        return resumeMapper.selectByIds(list);
    }


}




